#ifndef _FEATHER_H_
#define _FEATHER_H_

#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_log.h"
#include "driver/spi_master.h"
//#define USE_KIT
//#define USE_16BIT_SPI

#ifndef USE_KIT
#define USE_LED
#define USE_GPS
#define USE_BAT_ADC
#define USE_MPU9250
#define USE_MOT
#define USE_BLE_ADV
#define USE_BLE_SCAN
#define USE_WIFI_AP
#else
#define USE_MPU9250  1
#define USE_BLE_ADV  1
#define USE_BLE_SCAN 1
#define USE_WIFI_AP  1
#endif

#ifndef USET_KIT
#define MPU_MISO_PIN_NUM      18
#define MPU_MOSI_PIN_NUM      17
#define MPU_CLK_PIN_NUM       5
#define MPU_CS_PIN_NUM        21
#define MPU_INT_PIN_NUM       19
#define LICHEE_CS_PIN_NUM     34
#else
#define MPU_MISO_PIN_NUM      18
#define MPU_MOSI_PIN_NUM      17
#define MPU_CLK_PIN_NUM       5
#define MPU_CS_PIN_NUM        21
#endif

#define GPS_RX_PIN_NUM        4
#define GPS_TX_PIN_NUM        16
#define GPS_TIMEPULSE_PIN_NUM 2
#define GPS_INT_PIN_NUM       15
#define GPS_RESET_PIN_NUM     13

#define BAT_ADC_PIN_NUM   35

#define MOT1_PIN_NUM   27  
#define MOT2_PIN_NUM   22  
#define MOT3_PIN_NUM   32  
#define MOT4_PIN_NUM   25 

#define LED1_PIN_NUM   14
#define LED2_PIN_NUM   23
#define LED3_PIN_NUM   33
#define LED4_PIN_NUM   26

#define MOT_NUM               4
#define MOT12_HS_TIMER        LEDC_TIMER_0
#define MOT_HS_MODE           LEDC_HIGH_SPEED_MODE
#define MOT_HS_CH1_GPIO       MOT1_PIN_NUM 
#define MOT_HS_CH1_CHANNEL    LEDC_CHANNEL_0
#define MOT_HS_CH2_GPIO       MOT2_PIN_NUM 
#define MOT_HS_CH2_CHANNEL    LEDC_CHANNEL_1

#define MOT34_HS_TIMER        LEDC_TIMER_1
#define MOT_HS_MODE           LEDC_HIGH_SPEED_MODE
#define MOT_HS_CH3_GPIO       MOT3_PIN_NUM 
#define MOT_HS_CH3_CHANNEL    LEDC_CHANNEL_2
#define MOT_HS_CH4_GPIO       MOT4_PIN_NUM 
#define MOT_HS_CH4_CHANNEL    LEDC_CHANNEL_3


#define MOT_DUTY_DEAD_AERO  (0)
#define MOT_DUTY_FULL_AERO  (4095-MOT_DUTY_DEAD_AERO)
#ifdef USE_MOT
extern int mot_duty[4];
extern int mot_sata[4];
#endif

extern char dev_name[12];

static inline uint32_t get_ms_stamp(unsigned long *t)
{
    return 0;
}

static inline void delay(uint32_t t)
{

}

#if (defined USE_BLE_ADV) || (defined USE_BLE_SCAN)
void ble_init(void);
#endif
#ifdef USE_WIFI_AP
void wifi_ap_init(void);
void wifi_data_interactive_task(void *pvParameter);
#endif
#ifdef USE_LED
void led_task(void *pvParameter);
#endif
#ifdef USE_MOT
void mot_task(void *pvParameter);
#endif
#ifdef USE_MPU9250
extern spi_device_handle_t mpuxx_spi;
void mpuxx_task(void *pvParameter);
#ifdef USE_16BIT_SPI
uint8_t spi_write_byte(spi_device_handle_t spi,uint8_t regAddr,uint8_t data);
uint8_t spi_read_byte(spi_device_handle_t spi,uint8_t regAddr);
#endif
uint8_t spi_rw_byte(spi_device_handle_t spi,uint8_t data);
#endif





#endif

